#include "logfilters.h"

CLogFiltersImpl::CLogFiltersImpl(void)
{

}
CLogFiltersImpl::~CLogFiltersImpl(void)
{
	logi("CLogFiltersImpl::~CLogFiltersImpl");
}
std_method_impl CLogFiltersImpl::Init(int Argc, basic_tchar* Argv[], IBase* pRot, IBase* pBase)
{
	rc_assert(pRot != NULL, E_FAIL)

	HRESULT hr = S_OK;
	hr = pRot->QueryInterface(IID_IComRotMessage, (void**)&m_pRot);
	rc_assert(hr == S_OK, E_FAIL)

	return S_OK;
}
std_method_impl CLogFiltersImpl::Uninit()
{

	return S_OK;
}
std_method_impl CLogFiltersImpl::Start(_pinstance hInstance, UINT uType)
{
	CThreadPool::StartThreadPool(5);
	CTimeThread::SetMilliSecond(50 * 1000);
	CTimeThread::Start_Tm_Thread();

	m_sem.Wait();

	return S_OK;
}
std_method_impl CLogFiltersImpl::Stop(UINT uExitCode)
{
	logi("CThreadPool::StopThreadPool");
	CThreadPool::StopThreadPool();
	logi("CTimeThread::Stop_Tm_Thread");
	CTimeThread::Stop_Tm_Thread();
	return S_OK;
}

std_method_impl CLogFiltersImpl::PostLog(UCHAR* pBuf, ULONG Size)
{
	HRESULT		hr = S_OK;

	rc_assert(pBuf != NULL, E_FAIL)
	rc_assert(Size != 0, E_FAIL)

	LogDataPtr ptr = new LogData(pBuf, Size);
	rc_assert(ptr != NULL, E_FAIL)

	SYNC_OBJ(&m_lock);
	{
		m_ListJson.push_back(ptr);
	}

	return S_OK;// CThread::PostSem();
}

std_method_impl CLogFiltersImpl::SendPackage(UCHAR* pBuf, ULONG Size)
{
	return E_FAIL;
}

std_method_impl CLogFiltersImpl::Time_Thread_Run()
{
	return S_OK;
}
std_method_impl CLogFiltersImpl::ThreadPool_Run(void* data, void* ctx)
{

	return S_OK;
}
std_method_impl CLogFiltersImpl::ThreadPool_Start()
{
	m_sem.Post();
	return S_OK;
}
std_method_impl CLogFiltersImpl::ThreadPool_Stop()
{
	return S_OK;
}
std_method_impl CLogFiltersImpl::ThreadPool_Error()
{
	return S_OK;
}
